package emulator.hardware.memory;

import java.util.Arrays;

import emulator.hardware.bus.Bus;
import emulator.hardware.debug.BusWatchException;
import emulator.util.ByteArrayWrapper;

public class MemoryBlock extends ByteArrayWrapper implements Bus {

	public MemoryBlock(int size)
	{
		super(new byte [size]);
		Arrays.fill(getData(), (byte)0);
	}
	
	@Override
	public int read(int address) throws UnmappedMemoryException, BusWatchException {
		return ((int) getData()[address]) & 0xFF;
	}

	@Override
	public void write(int address, int data) throws UnmappedMemoryException, BusWatchException {
		getData()[address] = (byte) (data & 0xFF);
	}
	
}
